{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c6af17e9",
   "metadata": {},
   "source": [
    "-----\n",
    "* 时间：2022/10/24 week 10\n",
    "* 记录人：林鑫磊\n",
    "-----\n",
    "# 本周学习目标\n",
    "> 1.while循环\n",
    "> 2.购物车实践\n",
    "## 1.while循环\n",
    "* while循环：当某种条件成立时，停止循环\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f788fc13",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你是风儿我是沙，啦啦啦啦... 0\n",
      "你是风儿我是沙，啦啦啦啦... 1\n",
      "你是风儿我是沙，啦啦啦啦... 2\n",
      "你是风儿我是沙，啦啦啦啦... 3\n",
      "你是风儿我是沙，啦啦啦啦... 4\n",
      "你是风儿我是沙，啦啦啦啦... 5\n",
      "你是风儿我是沙，啦啦啦啦... 6\n",
      "你是风儿我是沙，啦啦啦啦... 7\n",
      "你是风儿我是沙，啦啦啦啦... 8\n",
      "你是风儿我是沙，啦啦啦啦... 9\n"
     ]
    }
   ],
   "source": [
    "# 1.指定次数\n",
    "count = 0\n",
    "while True:\n",
    "    print(\"你是风儿我是沙，啦啦啦啦...\",count)\n",
    "    count = count+1\n",
    "    if count == 10:\n",
    "        break # 停止循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "acab8330",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (4121285781.py, line 14)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [26]\u001b[1;36m\u001b[0m\n\u001b[1;33m    if count<2:\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "# while True循环，可以让用户重复输入\n",
    "user01 = \"admin\"\n",
    "password01 = \"123456\"\n",
    "count = 0\n",
    "\n",
    "while True:\n",
    "    username = input(\"账号：\")\n",
    "    password = input(\"密码：\")\n",
    "    if user01 == username and password01 == password:\n",
    "        print(\"登录成功~欢迎\"+user01)\n",
    "        break # 终止循环\n",
    "    # 情景二：账号不存在或密码不正确，用户可以输入三次，三次之后一小时之后再来尝试\n",
    "    else:\n",
    "    if count<2:\n",
    "        print(\"账号不存在或密码不正确！请重新输入！您还有\"+str(2-count)+\"次尝试机会\")\n",
    "    else:\n",
    "        print(\"账号不存在或密码不正确！请一小时之后再来尝试\")\n",
    "        break\n",
    "        count = count+1\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "51fa0555",
   "metadata": {},
   "source": [
    "## 2.购物车"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "e70d209a",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-45-f85b01453dc0>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-45-f85b01453dc0>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    for i in range(4)\u001b[0m\n\u001b[1;37m                     ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "for i in range(4)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "8030f80b",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (<ipython-input-50-137c7144f09f>, line 11)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-50-137c7144f09f>\"\u001b[1;36m, line \u001b[1;32m11\u001b[0m\n\u001b[1;33m    print(\"-------商品列表------\")\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "#  1.\n",
    "\n",
    "product_list = [\n",
    "    [\"蜜雪柠檬水\",6],\n",
    "    [\"蜜桃四季春\",10],\n",
    "    [\"芒果奶盖\",12],\n",
    "    [\"葡萄波波奶茶\",8]\n",
    "]\n",
    "#AliPay = input(\"请输入余额：\")\n",
    "while True:\n",
    "print(\"-------商品列表------\")\n",
    "for i in range(4):\n",
    "       print(\"商品序号\",\"(\"+str(i)+\"):\",product_list[i][0],str(product_list[i][1])+\"元\") #  格式化输出\n",
    "        user_choice = input(\"请输入商品编号：\")\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "caf9d0be",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
